Hands On: Open an Existing Report

In this example, you will open an existing report file in Visual Basic. This will demonstrate how to import existing reports (*.RPT files) and allow you to become familiar with the Report Designer Component user interface.

Before you begin

Ensure that you have completed installation of the Report Designer Component files and make note of the installation directory if you did not accept the default selection. This information will be used to locate the sample report files.

Step by step

1 Open the Visual Basic 5.0/6.0 application, if it is not already running.
2 Create a new Standard EXE project by either selecting one from the Visual Basic start up dialog or navigating to New Project under the File menu.
3 Insert the Report Designer in your sample project form. Navigate to the Project menu, select Add Crystal Reports 7.0.


4 The Report Gallery window will appear and displays a series of buttons representing the different types of Report Experts that are available.

Since you will be opening an existing report file, click on the Import Report button.
5 Navigate to the Xtreme sample reports directory. If you selected the default file locations at install the path will be:
"X:\Program Files\Seagate Software\Crystal Reports\Reports\Xtreme"
where "X" is the install drive letter.

Select the "wwsales" report file and click Open. Depending on your specific setup, you may be presented with another dialog - click OK for now. The Report Designer Component will be added to your project and in a few seconds, the report layout will be displayed in the design window. Report files created by any version of Seagate Crystal Reports can imported in this manner.

Take some time to explore the Report Designer design time interface. Rolling your mouse over the designer toolbar just above the ruler will display brief descriptions of the various buttons. Right Clicking on report elements will bring up additional formatting options and information. For a brief overview of the various buttons on the designer toolbar click here.
6 Before you run the report, select Form2 and View Code for this form. You should see Visual Basic code similar to this:

Dim Report As New CrystalReport1

Private Sub Form_Load()
CRViewer1.ReportSource = Report
CRViewer1.ViewReport

End Sub

Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth

End Sub

This default code was inserted by the Report Designer Component and will point the run time Crystal Report Viewer at the report and display the results. This makes it easy to flip between the report design window and the finished report. You could add to or modify this code, but for now you’ll just view the report.
7 From the Visual Basic Run menu select the Start (F5) command or click on the Start button on the Visual Basic toolbar. After a few seconds, you will see a form displaying the finished report in the Crystal Report Viewer. You may resize the form by dragging the lower right hand corner.

Try using the viewer Group Tree or other navigation buttons shown above to navigate around the report. Double-click on one of the segments in the pie graph to drill-down for even more detail. Since you added not additional code, this report uses the default actions available in the viewer. Later, you'll see how to use code to modify how the viewer looks and behaves.

Now that you have opened and viewed a report, feel free to go back and explore some of the right-click and property settings in the Report Designer window. You may also want to browse the CRViewer class of the CRVIEWERLibCtl object to see some of the properties and methods that you can use to customize the appearance of the viewer at run time.


For the latest information about this product, please visit the web site at www.seagatesoftware.com/scrvbasic.

Copyright ⌐ 1998 Seagate Software Inc. All rights reserved. Click here for additional information.